import axiosInstance from "../axiosInstance";

const userInfo = {
    //登录
    checkLogin({ zh, password }) {
        return axiosInstance.post('/userInfo/checkLogin', {
            zh,
            password
        })
    },

    //注册
    add({ nickName, user_sex, user_phone, user_email, user_photo, password }) {
        return axiosInstance.post('/userInfo/add', {
            nickName,
            user_sex,
            user_phone,
            user_email,
            user_photo,
            password
        })
    },

    //上传头像
    uploadUserPhoto(file) {
        let formData = new FormData();
        formData.append('user_photo', file);
        return axiosInstance.post('/userInfo/uploadUserPhoto', formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
    },

    //修改用户信息
    update({ id, nickName, user_sex, user_phone, user_email, user_photo }) {
        return axiosInstance.post('/userInfo/update', {
            id,
            nickName,
            user_sex,
            user_phone,
            user_email,
            user_photo,
        })
    }

}

export default userInfo;